part of 'cell.dart';

@deprecated
class LabelCell extends StatelessWidget {
  final Widget? title;
  final Widget? subTitle;
  final Widget? rightWidget;
  final bool isShowBottomLine;
  final double? verticalSpacing;
  final double? horizontalSpacing;
  final EdgeInsetsGeometry? padding;
  final EdgeInsetsGeometry? margin;
  final GestureTapCallback? onTap;
  final Color? background;
  final bool enable;
  final Color? bottomLineColor;
  final double? bottomLineWidth;

  const LabelCell({
    super.key,
    this.title,
    this.subTitle,
    this.rightWidget,
    this.isShowBottomLine = false,
    this.verticalSpacing,
    this.padding,
    this.horizontalSpacing,
    this.onTap,
    this.margin,
    this.background,
    this.enable = true,
    this.bottomLineColor,
    this.bottomLineWidth,
  });

  LabelCell.title({
    super.key,
    String? title,
    String? subTitle,
    String? hint,
    TextStyle titleStyle = const TextStyle(fontSize: 16.0, color: Colors.black),
    TextStyle subTitleStyle = const TextStyle(fontSize: 14.0, color: Colors.blueGrey),
    TextStyle hintStyle = const TextStyle(fontSize: 14.0, color: Colors.grey),
    this.rightWidget,
    this.isShowBottomLine = false,
    this.verticalSpacing,
    this.padding,
    this.horizontalSpacing,
    bool isMust = false,
    this.onTap,
    this.margin,
    this.background,
    this.bottomLineColor,
    this.bottomLineWidth,
    this.enable = true,
  })
      : this.title = Text.rich(
    TextSpan(text: title ?? '', style: titleStyle, children: [
      TextSpan(
        text: isMust ? ' *' : '',
        style: titleStyle.copyWith(color: Colors.red),
      )
    ]),
    maxLines: 1,
    overflow: TextOverflow.ellipsis,
  ),
        this.subTitle = Text(
          TextHelper.checkText(subTitle ?? '', defaultText: hint ?? ''),
          style: ObjectUtil.isEmpty(subTitle) ? hintStyle : subTitleStyle,
          maxLines: 1,
          overflow: TextOverflow.ellipsis,
        );

  LabelCell.area({
    super.key,
    String? title,
    String? subTitle,
    String? hint,
    TextStyle titleStyle = const TextStyle(fontSize: 16.0, color: Colors.black),
    TextStyle subTitleStyle = const TextStyle(fontSize: 14.0, color: Colors.blueGrey),
    TextStyle hintStyle = const TextStyle(fontSize: 14.0, color: Colors.grey),
    this.rightWidget,
    this.isShowBottomLine = false,
    this.verticalSpacing,
    this.padding,
    this.horizontalSpacing,
    bool isMust = false,
    this.onTap,
    this.margin,
    this.background,
    this.bottomLineColor,
    this.bottomLineWidth,
    this.enable = true,
  })
      : this.title = Text.rich(
    TextSpan(text: title ?? '', style: titleStyle, children: [
      TextSpan(
        text: isMust ? ' *' : '',
        style: titleStyle.copyWith(color: Colors.red),
      )
    ]),
    maxLines: 1,
    overflow: TextOverflow.ellipsis,
  ),
        this.subTitle = Text(
          TextHelper.checkText(subTitle ?? '', defaultText: hint ?? ''),
          style: ObjectUtil.isEmpty(subTitle) ? hintStyle : subTitleStyle,
        );

  LabelCell.select({
    super.key,
    String? title,
    String? subTitle,
    String? hint,
    TextStyle titleStyle = const TextStyle(fontSize: 16.0, color: Colors.black),
    TextStyle subTitleStyle = const TextStyle(fontSize: 14.0, color: Colors.blueGrey),
    TextStyle hintStyle = const TextStyle(fontSize: 14.0, color: Colors.grey),
    bool isHideArrow = false,
    this.isShowBottomLine = false,
    this.verticalSpacing,
    this.padding,
    this.horizontalSpacing,
    bool isMust = false,
    this.onTap,
    this.margin,
    this.background,
    this.bottomLineColor,
    this.bottomLineWidth,
    this.enable = true,
  })
      : this.title = Text.rich(
    TextSpan(text: title ?? '', style: titleStyle, children: [
      TextSpan(
        text: isMust ? ' *' : '',
        style: titleStyle.copyWith(color: Colors.red),
      )
    ]),
    maxLines: 1,
    overflow: TextOverflow.ellipsis,
  ),
        this.subTitle = Text(
          TextHelper.checkText(subTitle, defaultText: hint),
          style: ObjectUtil.isEmpty(subTitle) ? hintStyle : subTitleStyle,
          maxLines: 1,
          overflow: TextOverflow.ellipsis,
        ),
        this.rightWidget = Visibility(
            visible: !isHideArrow,
            child: Image.asset(
              'assets/images/capital_right_arrow.png',
              width: 10.0,
              height: 10.0,
            ));

  LabelCell.edit({
    super.key,
    String? title,
    String? value,
    String? hint,
    TextStyle titleStyle = const TextStyle(fontSize: 16.0, color: Colors.black),
    TextStyle valueStyle = const TextStyle(fontSize: 14.0, color: Colors.blueGrey),
    TextStyle hintStyle = const TextStyle(fontSize: 14.0, color: Colors.grey),
    TextEditingController? controller,
    this.isShowBottomLine = false,
    this.verticalSpacing,
    this.padding,
    this.horizontalSpacing,
    bool isMust = false,
    this.onTap,
    this.margin,
    this.background,
    this.rightWidget,
    this.bottomLineColor,
    this.bottomLineWidth,
    this.enable = true,
  })
      : this.title = Text.rich(
    TextSpan(text: title ?? '', style: titleStyle, children: [
      TextSpan(
        text: isMust ? ' *' : '',
        style: titleStyle.copyWith(color: Colors.red),
      )
    ]),
    maxLines: 1,
    overflow: TextOverflow.ellipsis,
  ),
        this.subTitle = CupertinoTextField(
          controller: controller,
          style: Platform.isIOS ? valueStyle : valueStyle.copyWith(height: 1.2),
          placeholder: hint,
          placeholderStyle: hintStyle,
          decoration: const BoxDecoration(),
        );

  @override
  Widget build(BuildContext context) {
    return IgnorePointer(
      ignoring: !enable,
      child: GestureDetector(
        onTap: onTap,
        child: Container(
          padding: padding,
          margin: margin,
          decoration: BoxDecoration(
            color: background ?? Colors.transparent,
            border: Border(
              bottom: BorderSide(color: isShowBottomLine ? this.bottomLineColor ?? Colors.black.withOpacity(0.05) : Colors.transparent,
                  width: this.bottomLineWidth ?? 0.5),
            ),
          ),
          child: Row(
            children: [
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    title ?? Gaps.empty,
                    Gaps.vGap(verticalSpacing ?? 0),
                    subTitle ?? Gaps.empty,
                  ],
                ),
              ),
              Gaps.hGap(horizontalSpacing ?? 0),
              rightWidget ?? Gaps.empty,
            ],
          ),
        ),
      ),
    );
  }
}
